<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="./lib/vue-2.5.9.js"></script>
  <style>
    .normal {
      color: blue;
    }

    .active {
      color: red;
      font-weight: bold;
    }
  </style>
</head>

<body>
  <div id="app">
    <ul>
      <li v-for="(item, index) in list" :key="item.id" :class="['normal', { active: index == selectedIndex ? true : false }]" @click="changeIndex(index)">{{ item.id }} ------ {{ item.name }}</li>
    </ul>
  </div>

  <script>
    // 创建 Vue 实例，得到 ViewModel
    var vm = new Vue({
      el: '#app',
      data: {
        selectedIndex: 0, // 设置默认选中项的索引
        list: [
          { id: 1, name: '张三' },
          { id: 2, name: '李四' },
          { id: 3, name: '柯南' },
          { id: 4, name: '毛利' }
        ]
      },
      methods: {
        changeIndex(index) {
          this.selectedIndex = index
        }
      }
    });
  </script>
</body>

</html>